
/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __SCREENSAVER_ABILITY_SLICE_H__
#define __SCREENSAVER_ABILITY_SLICE_H__

#include <ability_loader.h>
#include <common/task.h>
#include <components/ui_image_view.h>
#include <components/ui_label.h>
#include <components/root_view.h>

#include "event_listener.h"
#include "popup_dialog.h"

namespace OHOS {

class ScreenSaverAbilitySlice : public AbilitySlice, Task {
public:
    ScreenSaverAbilitySlice();
    ~ScreenSaverAbilitySlice();

    void Callback() override;
    int DialogDisplay(const char *msg, int type, int timeout);

protected:
    void OnStart(const Want &want) override;
    void OnInactive() override;
    void OnActive(const Want &want) override;
    void OnBackground() override;
    void OnStop() override;
private:
    RootView *rootView_ { nullptr };

    UIImageView *background_ { nullptr };
    UIImageView *clockIcon_ { nullptr };
    UIImageView *weatherIcon_ { nullptr };

    UILabel *timeLabel_ { nullptr };
    UILabel *dateLabel_ { nullptr };
    UILabel *weatherLabel_ { nullptr };
    UILabel *pm25Label_ { nullptr };
    UILabel *pm25QatLabel_ { nullptr };

    PopupDialog *dialogWin_ { nullptr };
    HoodsButtonClickListener *onClick_ { nullptr };

    bool isActivity_ = false;
    bool quit_ = false;
    int minute_ = -1;

    void SetTimeDate();
    void SetWeatherInfo();
    void UpdateTimeDate();
};

}

#endif  /* __SCREENSAVER_ABILITY_SLICE_H__ */
